﻿//信息基表
//创建时间: 2010-10-19
//创建作者: 李晓忠
//功能说明: CMS系统 信息基表 
//最后修改: 2010-10-19
//最后修改: 2010-10-20 李晓忠 添加保存模型信息。
//最后修改: 2010-10-21 李晓忠 GetDataSet。修改SaveNewDoc,添加DeleteInfoByExtendId
//最后修改: 2010-11-2 李晓忠 添加置顶操作\精华操作\排序操作
//最后修改: 2010-11-17 李晓忠 添加模型信息表某一字段值
//最后修改: 2010-11-22 李晓忠 添加更新计划发布时间
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Reflection;

using TRPOP.Common;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.DALFactory
{
    public interface IContentDAL
    {

        ///	<summary>
        ///	保存
        ///	</summary>
        ///	<param name="ContentInfo"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult Save(ContentInfo info);

        ///	<summary>
        ///	获取实体
        ///	</summary>
        ///	<param name="contentId"></param>
        ///	<returns>ContentInfo</returns>
        ContentInfo GetInfoById(int id);

        ///	<summary>
        ///	逻辑删除 PubStatus=-1
        ///	</summary>
        ///	<param name="id"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult DeleteInfoById(int id);

        ///	<summary>
        ///	逻辑删除 PubStatus=-1
        ///	</summary>
        ///	<param name="ids"></param>
        ///	<returns>EnumSubmitResult</returns>
        EnumSubmitResult DeleteInfoByIds(string ids);

        ///	<summary>
        ///	自定义列表（无分页）
        ///	</summary>
        ///	<param name="topn">前N条，为0时表示所有符合条件的</param>
        ///	<param name="condition">自定义条件，要以And开头</param>
        ///	<param name="orderby">排序，不需要Order by </param>
        ///	<returns>List<ContentInfo></returns>
        List<ContentInfo> GetListByCondition(int topn, string condition, string orderby);

        ///	<summary>
        ///	自定义列表（分页）
        ///	</summary>
        ///	<returns>List<ContentInfo></returns>
        List<ContentInfo> GetListByPager(int pageNumber, int pageSize, string condition, string orderby, out int recordCount);

       /// <summary>
       /// 保存信息
       /// </summary>
       /// <param name="info">基本信息</param>
       /// <param name="model">模型</param>
       /// <param name="modelfieldlist">模型字段</param>
       /// <returns></returns>
        EnumSubmitResult SaveNewDoc(ContentInfo info, List<ModelFieldInfoWithTableName> modelfieldlist);


        /// <summary>
        /// 获取信息 GetDataSet
        /// </summary>
        /// <param name="strTable">表名</param>
        /// <param name="strFields">字段</param>
        /// <param name="strCondition">条件</param>
        /// <param name="strOrderBy">排序</param>
         /// <returns></returns>
        DataSet GetDataSet(string strTable, string strFields, string strCondition, string strOrderBy);
        /// <summary>
        ///  删除信息 DeleteInfoByExtendId
        /// </summary>
        /// <param name="ExtendId"></param>
        /// <param name="ExtendTableName"></param>
        /// <returns></returns>
        EnumSubmitResult DeleteInfoByExtendId(int ExtendId, string ExtendTableName);

        /// <summary>
        /// 置顶操作
        /// </summary>
        /// <param name="NodeId"></param>
        /// <param name="ExtendIds"></param>
        /// <param name="TopWeight"></param>
        /// <returns></returns>
        EnumSubmitResult SetTopWeightByIds(string Ids, int TopWeight);

        /// <summary>
        /// 精华操作
        /// </summary>
        /// <param name="NodeId"></param>
        /// <param name="ExtendIds"></param>
        /// <param name="EliteWeight"></param>
        /// <returns></returns>
        EnumSubmitResult SetEliteWeightByIds(string Ids, int EliteWeight);

        /// <summary>
        /// 排序操作
        /// </summary>
        /// <param name="NodeId"></param>
        /// <param name="ExtendIds"></param>
        /// <param name="DisplayOrder"></param>
        /// <returns></returns>
        EnumSubmitResult SetDisplayOrderByIds(string Ids, int DisplayOrder);

        /// <summary>
        /// 更新点击数
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="Click"></param>
        /// <returns></returns>
        EnumSubmitResult SetClickByInfoId(string ids, int Click);

        /// <summary>
        /// 点击数加1 SetClickAdd
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        EnumSubmitResult SetClickAdd(string ids);

        /// <summary>
        /// 恢复逻辑删除 PubStatus=0
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        EnumSubmitResult RestoreDeleteInfoByIds(string ids);

        /// <summary>
        /// 永久删除, 后面需要添加删除相关评论等信息。
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        EnumSubmitResult DestroyDeleteInfoByIds(string ids);

        /// <summary>
        /// 文章转移操作 CutDocToNewNode
        /// </summary>
        /// <param name="Ids"></param>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        EnumSubmitResult CutDocToNewNode(string Ids, int NodeId);

        /// <summary>
        /// 文章复制操作CopyDocToNewNode
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="NodeId"></param>
        /// <param name="AdminId"></param>
        /// <param name="AdminTime"></param>
        /// <returns></returns>
        EnumSubmitResult CopyDocToNewNode(string ids, int NodeId, int AdminId, DateTime AdminTime);

        /// <summary>
        /// 清空回收站 EmptyRecycleByNodeId
        /// </summary>
        /// <param name="NodeId"></param>
        /// <returns></returns>
        EnumSubmitResult EmptyRecycleByNodeId(int NodeId);
        /// <summary>
        /// 永久删除, 后面需要添加删除相关评论等信息。
        /// </summary>
        /// <param name="nodeid"></param>
        /// <returns></returns>
        EnumSubmitResult DestroyDeleteInfoByNodeId(int nodeid);
        /// <summary>
        /// 获取信息表1条数据
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="ExtendId"></param>
        /// <param name="m_ModelFieldInfoList"></param>
        /// <returns></returns>
        List<ModelFieldInfoWithTableName> GetContentData(string tableName, int ExtendId, List<ModelFieldInfoWithTableName> m_ModelFieldInfoList);
        /// <summary>
        /// 添加模型信息表某一字段值
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="strField">字段</param>
        /// <param name="ContentId">基表信息Id</param>
        /// <returns></returns>
        object GetFieldValue(string tableName, string strField, int ContentId);

        /// <summary>
        /// 更新计划发布时间
        /// </summary>
        /// <param name="Ids">ContentId</param>
        /// <param name="PubTime">计划发布时间</param>
        /// <returns></returns>
        EnumSubmitResult SetPubTimeByIds(string Ids, DateTime PubTime);

        /// <summary>
        /// 获取某结点下的信息数
        /// </summary>
        /// <param name="strNodeId">结点集合</param>
        /// <param name="intPubstatus">发布状态</param>
        /// <returns></returns>
        int GetContentCount(string strNodeId, string strPubstatus);

        /// <summary>
        /// 获取关键字相关信息的Id
        /// </summary>
        /// <param name="SearchKey">搜索关键字</param>
        /// <param name="NodeId">结点Id</param>
        /// <returns></returns>
        string GetExtendIdBySearchKey(string SearchKey, int NodeId);

        /// <summary>
        /// 查询关键字 拼接查询的SQL语句
        /// </summary>
        /// <param name="SearchKey">关键字</param>
        /// <param name="NodeId">结点id</param>
        /// <returns></returns>
        string GetExtendIdBySearchKeySQL(string SearchKey, int NodeId);
        /// <summary>
        /// 获取实链接的虚链接信息
        /// </summary>
        /// <param name="ContentIds"></param>
        /// <returns></returns>
        List<ContentInfo> GetVirtualLink(string ContentIds);

        /// <summary>
        /// 删除基表信息(只删除基表信息)
        /// </summary>
        /// <param name="ContendId"></param>
        /// <returns></returns>
        EnumSubmitResult DeleteContendInfoByContendId(int ContendId);

         /// <summary>
         /// 分页获取ContentId
         /// </summary>
         /// <param name="pageNumber"></param>
         /// <param name="pageSize"></param>
         /// <param name="condition"></param>
         /// <param name="orderby"></param>
         /// <param name="recordCount"></param>
         /// <returns></returns>
         List<ContentInfo> GetContetnIDListByPager(int pageNumber, int pageSize, string condition, string orderby, out int recordCount);

        /// <summary>
        /// 同步虚结点
        /// </summary>
        /// <param name="oVirualNode"></param>
        /// <param name="oParentNode"></param>
        /// <param name="intUserID"></param>
        /// <returns></returns>
        EnumSubmitResult UpdateAllSyncContent(NodeInfo oVirualNode, NodeInfo oParentNode, int intUserID);

        /// <summary>
        /// 获取信息列表（$_title:标题字段）
        /// </summary>
        /// <param name="nodeId"></param>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <param name="condition"></param>
        /// <param name="orderby"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        DataSet GetContentListByPager(int nodeId, int pageNumber, int pageSize, string condition, string orderby, out int recordCount);
    }

    public sealed partial class DataAccess
    {
        public static IContentDAL CreateContentDAL()
        {
            string className = path + ".ContentDAL";
            return (IContentDAL)Assembly.Load(path).CreateInstance(className);
        }
    }
}
